package cn.edu.ctbu.finaltest.service.StudentCourseMessageService.impl;


import cn.edu.ctbu.finaltest.service.StudentCourseMessageService.StudentCourseMessageService;
import cn.edu.ctbu.finaltest.vo.StudentCourseMessage;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 学生课程信息
 */
@Service
public class StudentCourseMessageImplService implements StudentCourseMessageService {

    /**
     * 课号模糊查找
     * @param cno
     * @param SCMList
     * @return
     */
    public List<StudentCourseMessage> findByCnoLike(String cno, List<StudentCourseMessage> SCMList){
        List<StudentCourseMessage> studentCourseMessages = new ArrayList<>();
        for (int i = 0;i < SCMList.size();i++){
            if (SCMList.get(i).getCno().indexOf(cno) >= 0){
                studentCourseMessages.add(SCMList.get(i));
            }
        }
        return studentCourseMessages;
    }

    /**
     * 课名模糊查找
     * @param cname
     * @param SCMList
     * @return
     */
    public List<StudentCourseMessage> findByCnameLike(String cname,List<StudentCourseMessage> SCMList){
        List<StudentCourseMessage> studentCourseMessages = new ArrayList<>();
        for (int i = 0;i < SCMList.size();i++){
            if (SCMList.get(i).getCname().indexOf(cname) >= 0){
                studentCourseMessages.add(SCMList.get(i));
            }
        }
        return studentCourseMessages;
    }



    /**
     * 教师姓名模糊查询
     * @return
     */
    public List<StudentCourseMessage> findByTeacherLike(String name,List<StudentCourseMessage> SCMList){
        List<StudentCourseMessage> studentCourseMessages = new ArrayList<>();
        for (int i = 0;i < SCMList.size();i++){
            if (SCMList.get(i).getTeacher().indexOf(name) >= 0){
                studentCourseMessages.add(SCMList.get(i));
            }
        }
        return studentCourseMessages;
    }


    /**
     * 课号精确查找
     * @param cno
     * @param SCMList
     * @return
     */
    public List<StudentCourseMessage> findByCno(String cno,List<StudentCourseMessage> SCMList){
        List<StudentCourseMessage> studentCourseMessages = new ArrayList<>();
        for (int i = 0;i < SCMList.size();i++){
            if (SCMList.get(i).getCno().equals(cno)){
                studentCourseMessages.add(SCMList.get(i));
            }
        }
        return studentCourseMessages;
    }

    /**
     * 课名精确查找
     * @param cname
     * @param SCMList
     * @return
     */
    public List<StudentCourseMessage> findByCname(String cname,List<StudentCourseMessage> SCMList){
        List<StudentCourseMessage> studentCourseMessages = new ArrayList<>();
        for (int i = 0;i < SCMList.size();i++){
            if (SCMList.get(i).getCname().equals(cname)){
                studentCourseMessages.add(SCMList.get(i));
            }
        }
        return studentCourseMessages;
    }


    /**
     * 教师姓名精确查询
     * @return
     */
    public List<StudentCourseMessage> findByTeacher(String name,List<StudentCourseMessage> SCMList){
        List<StudentCourseMessage> studentCourseMessages = new ArrayList<>();
        for (int i = 0;i < SCMList.size();i++){
            if (SCMList.get(i).getTeacher().equals(name)){
                studentCourseMessages.add(SCMList.get(i));
            }
        }
        return studentCourseMessages;
    }


}
